<?php // no direct access
defined('_JEXEC') or die('Restricted access');
$col= 1 ;
$pwidth= ' width'.floor ( 100 / $products_per_row );
if ($products_per_row > 1) { $float= "floatleft";}
else {$float="center";}
?>
<div class="vmgroup<?php echo $params->get( 'moduleclass_sfx' ) ?>">

<?php if ($headerText) { ?>
	<div class="vmheader"><?php echo $headerText ?></div>
<?php }
if ($display_style =="div") { ?>
<div class="vmproduct<?php echo $params->get('moduleclass_sfx'); ?>">
<?php foreach ($products as $product) { ?>
	<div class="<?php echo $pwidth ?> <?php echo $float ?>"><div class="spacer">
  <div class="cat-image">   
<?php
 if (!empty($product->images[0]) )
 $image = $product->images[0]->displayMediaThumb('class="featuredProductImage" border="0"',true,'class="imgage"') ;
 else $image = '';
 echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$image,array('title' => $product->product_name) );

 ?>
 <h3>
<?php  $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.
$product->virtuemart_category_id); ?>		<a href="<?php echo $url ?>"><?php echo $product->product_name ?></a>		<?php	echo '<div class="clear"></div>';
 ?>
 </h3>
 	<div class="cat-view">	
             <?php /** @todo make image popup */
				echo $product->images[0]->displayMediaThumb('class="browseProductImage" border="0" title="'.$product->product_name.'" ',true,'class="modal"');
			?>
             </div>
  <div class="catProductPrice">
  <?php if ($show_price) {
 // 		echo $currency->priceDisplay($product->prices['salesPrice']);
 echo '<span class="label">' .JText::_('Price:')."</span>";
  echo '<span class="price">';
 if (!empty($product->prices['salesPrice'] ) ) echo $currency->createPriceDiv('salesPrice','',$product->prices,true);
 // 		if ($product->prices['salesPriceWithDiscount']>0) echo $currency->priceDisplay($product->prices['salesPriceWithDiscount']);
 if (!empty($product->prices['salesPriceWithDiscount']) ) echo $currency->createPriceDiv('salesPriceWithDiscount','',$product->prices,true);
 echo'</span>';
 }
  ?>
  </div>
 </div>
   		<div class="cat-info">
			<?php // Product Short Description
			
            if(!empty($product->product_s_desc)) { ?>
                <div class="product_desc">
                	<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 60, '...') ?>
                </div>
            <?php } ?>
            </div>
            
           <?php if ($show_addtocart) : ?>
		   <div class="cat-cart">   
		     <?php echo mod_virtuemart_product::addtocart($product);?>
		   </div>
		   <?php endif; ?>
</div>
</div>
	<?php
		if ($col == $products_per_row && $products_per_row && $col < $totalProd ) {
			echo "	</div><div style='clear:both;'>";
			$col= 1 ;
		} else {
			$col++;
		}
	} ?>
</div>
<br style='clear:both;' />

<?php
} else {
$last = count($products)-1;
$lastItem = $last;
?>

<ul class="vmproduct<?php echo $params->get('moduleclass_sfx'); ?>">
<?php foreach ($products as $k => $product) : 
if($k == 0) {
	$extraCls = ' first';
} elseif($k==intval($lastItem)) {
	$extraCls = ' last';
} else {
	$extraCls = '';
}

?>
 <li class="<?php echo $pwidth; ?> <?php echo $float.$extraCls; ?>">
 <div class="item-pro">
  <div class="item-pro-inner">
 <?php
 if (!empty($product->images[0]) )
			$image = $product->images[0]->displayMediaThumb('class="featuredProductImage" border="0"',false) ;
		else $image = '';
			echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$image,array('title' => $product->product_name) ); ?>
	<div class="pro-imfo">
    <?php 		
	$url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.
$product->virtuemart_category_id); ?>		<a class="lof-title" href="<?php echo $url ?>"><?php echo $product->product_name ?></a>	
<?php // Product Short Description
						if(!empty($product->product_s_desc)) { ?>
					<div class="product_desc">
						<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...') ?>
					</div>
					<?php } ?>
                  	<?php if ($show_price) {?>
        <div class="lof-price">                <span>
			<?php echo $currency->createPriceDiv('salesPrice','',$product->prices,true);?>
            </span> </div>
			 <?php if ($product->prices['salesPriceWithDiscount']>0) echo $currency->createPriceDiv('salesPriceWithDiscount','',$product->prices,true);
		}	?>
		 <?php 
		if ($show_addtocart) echo mod_virtuemart_product::addtocart($product);
		?>
        </div>
        </div>
        </div>
	</li>
<?php
	if ($col == $products_per_row && $products_per_row && $last ) {
		echo '
		</ul><div class="clear"></div>
		<ul  class="vmproduct'.$params->get('moduleclass_sfx')  .'">';
		$col= 1 ;
	} else {
		$col++;
	}
	$last--;
	endforeach; ?>
</ul><div class="clear"></div>

<?php }
	if ($footerText) : ?>
	<div class="vmfooter<?php echo $params->get( 'moduleclass_sfx' ) ?>">
		 <?php echo $footerText ?>
	</div>
<?php endif; ?>
</div>